package com.llc.mall.auth.interfaces;

import com.llc.mall.auth.application.command.UserAppService;
import com.llc.mall.auth.interfaces.vo.TokenInfoVo;
import com.mall4j.cloud.api.auth.vo.TokenInfoVO;
import com.llc.mall.auth.application.dto.UpdatePasswordDTO;
import com.llc.mall.common.core.response.ServerResponseEntity;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import jakarta.validation.Valid;


@RestController
@Tag(name = "密码")
public class PasswordController {

	@Resource
	private UserAppService userAppService;

	@PutMapping("/update_password")
	@Operation(summary = "更新密码" , description = "更新当前用户的密码, 更新密码之后要退出登录，清理token")
	public ServerResponseEntity<TokenInfoVo> updatePassword(@Valid @RequestBody UpdatePasswordDTO updatePasswordDTO) {
		userAppService.modifyPassword(updatePasswordDTO);
		return ServerResponseEntity.success();
	}

}
